#include "settinghelper.h"


QString SettingHelper::fileName="Setting.ini";

void SettingHelper::initSetting()
{
    QFileInfo file(fileName);
    bool isExist=file.exists();
    QSettings *psetting=new QSettings(fileName,QSettings::IniFormat);
    //写默认配置
    if(!isExist)
    {
        psetting->beginGroup("Data");
        psetting->setValue("DbPath","C:/Case/UserInfo.sqlite");
        psetting->endGroup();
    }
}

void SettingHelper::writeInit(QString key, QString value)
{
    QFileInfo file(fileName);
    bool isExist=file.exists();
    QSettings *psetting=new QSettings;
    //写配置
    if(isExist)
    {
        psetting->setValue(key,value);
    }
}

QString SettingHelper::getValue(QString groupName, QString key)
{
    QSettings *psetting=new QSettings(fileName,QSettings::IniFormat);
    QString strValue;

    psetting->beginGroup("Data");
    strValue=psetting->value(key,"C:/Case/UserInfo.sqlite").toString();
    psetting->endGroup();

    return strValue;
}
